package org.jgs1904.practice;

import javax.xml.transform.Source;

/**
 * @author: 默苍璃
 * @date: 2022-09-16 16:27
 * <p>
 * 用try ... catch捕获异常并处理。
 */
public class Practice01 {

    public static void main(String[] args) {
        String a = "12";
        String b = "x9";

        try {
            int c = stringToInt(a);
            int d = stringToInt(b);
            System.out.println(c * d);
        } catch (NumberFormatException e) {
            System.out.println("出错啦");
            e.printStackTrace();
        } catch (Exception e) {
            System.out.println("以外错误!!!");
        }

    }

    static int stringToInt(String s) {
        return Integer.parseInt(s);
    }

}
